// by Xeno
#define THIS_FILE "fn_newflagclient.sqf"
#include "x_setup.sqf"
private ["_box", "_flag", "_markertxt","_pos"];
if (!X_Client) exitWith {};

_flag = _this;
// TYRGHEN added alternative parameters.
_markername = format [QGVAR(paraflag%1), count __XJIPGetVar(resolved_targets)];
if (typename _this == typename []) then {
	_flag = _this select 0;
	_markername = _this select 1;
};

// TYRGHEN - added translation
_markertxt = if (GVAR(jumpflag_vec) == "") then {
	(localize "STR_DOM_MISSIONSTRING_2015")
} else {
	localize ("STR_DOM_MISSIONSTRING_2016")
};
[_markername, getPosASL _flag,"ICON","ColorYellow",[0.5,0.5],_markertxt,0,"mil_flag"] call FUNC(CreateMarkerLocal);
player reveal _flag;

// TYRGHEN
// if (GVAR(jumpflag_vec) == "") then {
	// _flag addAction [(localize "STR_DOM_MISSIONSTRING_296") call FUNC(BlueText), {_this spawn FUNC(paraj)}];
// } else {
	// _flag addAction [(format [(localize "STR_DOM_MISSIONSTRING_297"),[GVAR(jumpflag_vec),0] call FUNC(GetDisplayName)]) call FUNC(BlueText),{_this spawn FUNC(bike)},[GVAR(jumpflag_vec),1]];
// };
_flag addAction [(localize "STR_DOM_MISSIONSTRING_296") call FUNC(BlueText), {_this spawn FUNC(paraj)}];
if (GVAR(jumpflag_vec) != "") then {
	_flag addAction [(format [(localize "STR_DOM_MISSIONSTRING_297"),[GVAR(jumpflag_vec),0] call FUNC(GetDisplayName)]) call FUNC(BlueText),{_this spawn FUNC(bike)},[GVAR(jumpflag_vec),1]];
};

// TYRGHEN
_pos = _flag modelToWorld [0.5,0,0];
_pos set [2,0];
_box = GVAR(the_box) createVehicleLocal [0,0,100];
_box allowDamage false;
_box setPos _pos;
if (GVAR(WithJumpFlagsAmmo) == 0) then {
	[_box] call FUNC(init_boxnet);
} else {
	clearBackpackCargo _box;
	clearItemCargo _box;
	clearMagazineCargo _box;
	clearWeaponCargo _box;
	_box addBackpackCargo [GVAR(parachute_type),10];
};
// It's now synchronized in MP by ArmA
// _flag setFlagTexture (0 call FUNC(getownflagtex));

// TYRGHEN
if (GVAR(WithMHQTeleport) == 0) then {
	_tactionar = [(localize "STR_DOM_MISSIONSTRING_533") call FUNC(BlueText),{_this call FUNC(x_teleport)}];
	_flag addAction _tactionar;
};